/*
 * DbSource.h
 *
 *  Created on: 2018年1月3日
 *      Author: chuanjiang.zh@qq.com
 */

#ifndef DBSOURCE_H_
#define DBSOURCE_H_

#include "DbType.h"

namespace db
{

class DbSource
{
public:
	static const char* MYSQL;
	static const char* ODBC;
	static const char* SQLITE3;

	static const char* toString(DbSourceType t);
	static bool parse(const char* name, DbSourceType& t);

public:
	DbSource();
	virtual ~DbSource();

	DbSourceType     type;

    std::string     ip;
    uint16_t  		port;
    std::string     user;
    std::string     password;

    std::string     schema;		/// 是sqlite数据库时, 表示文件路径.

public:
    std::string getConnectString();

    bool set(const char* name);
    bool set(const std::string& name);

	bool check() const;

    bool isSqlite() const;

};


} /* namespace db */

#endif /* DBSOURCE_H_ */
